<script type="text/javascript">
    $.validator.setDefaults({
        submitHandler: function() {
            $.post("<?= site_url() ?>setup/update_room", {
                room_id: $('#room_id').val(),
                room: $('#room').val(),
                type: $('#type').val(),
				floor: $('#floor').val(),
				status: $('#status').val(),
				capacity: $('#capacity').val() 
            },
            function(data) {
                window.location = '<?php echo base_url();?>setup/room';
            });
        }
    });
    $(document).ready(function() {

        $("#formuser").keypress(function(e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $.validator.setDefaults({
                    submitHandler: function() {
                        $.post("<?= site_url() ?>setup/update_room", {
                            room_id: $('#room_id').val(),
							room: $('#room').val(),
							type: $('#type').val(),
							floor: $('#floor').val(),
							status: $('#status').val(),
							capacity: $('#capacity').val() 
                        },
                        function(data) {
                            window.location = '<?php echo base_url();?>setup/room';
                        });
                    }
                });
            }
        });

        $("#formuser").validate();
    });

    function cancel() {
        $.post("<?= site_url() ?>setup/result_room", function(data) {
			window.location = '<?php echo base_url();?>setup/room';
        });
    }

</script>

<form method="post" id="formuser" action="#" enctype="multipart/form-data" class="form-horizontal" role="form">
	<div class="col-md-offset-1">
		<div class="col-md-11">
			<div class="panel-body well">
				<h4><b class="caret"></b><b> Form - Edit Room</b></h4>
            <?php if (isset($detail_data) && !empty($detail_data)) { ?>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_room" class="control-label">Room Name<span style="color:red;">*</span></label></div>
					<div class="col-sm-4"><input type="text" class="form-control input-sm required" id="room" name="room" value="<?php echo $detail_data['MST_CATEGORY_DESC']; ?>"></div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_type" class="control-label">Type Name<span style="color:red;">*</span></label></div>
					<div class="col-sm-4">
						<select name="type" id="type" class="form-control input-sm required">
						<?php
							foreach($type_select as $type_select => $key)
							{
						?>
								<option value="<?php echo $key['MST_TYPE_ID'] ?>"<?php echo (strtoupper($detail_data['MST_TYPE_ID']) == $key['MST_TYPE_ID']) ? 'selected' : ''; ?>><?php echo $key['MST_TYPE_DESC'] ?></option>
						<?php		
							}
						?>							
						</select>
					</div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_floor" class="control-label">Floor<span style="color:red;">*</span></label></div>
					<div class="col-sm-3">
						<select name="floor" id="floor" class="form-control input-sm required">
						<?php
							foreach($floor_select as $floor_select => $key)
							{ 
						?>
								<option value="<?php echo $key['MST_FLOOR_DESC'] ?>"<?php echo (strtoupper($detail_data['MST_FLOOR_DESC']) == $key['MST_FLOOR_DESC']) ? 'selected' : ''; ?>><?php echo $key['MST_FLOOR_DESC'] ?></option>
						<?php	
							}
						?>			
						</select>
					</div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_status" class="control-label">Status<span style="color:red;">*</span></label></div>
					<div class="col-sm-3">
						<select name="status" id="status" class="form-control input-sm required">
							<option value="Y"<?php echo (strtoupper($detail_data['MST_CATEGORY_STATUS']) == 'Y') ? 'selected' : ''; ?>>Active</option>
                            <option value="N"<?php echo (strtoupper($detail_data['MST_CATEGORY_STATUS']) != 'Y') ? 'selected' : ''; ?>>Non Active</option>
						</select>
					</div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_capacity" class="control-label">Room Capacity</label></div>
					<div class="col-sm-3"><input type="text" class="form-control input-sm" id="capacity" name="capacity" value="<?php echo $detail_data['MST_CATEGORY_CAPACITY']; ?>"></div>					
				</div>
				<div class="col-sm-8" style="padding-bottom: 10px;">
					<div class="col-sm-4">
						&nbsp;
					</div>
				</div>
				<div class="col-sm-8">
                    <div class="col-sm-4"><label for="button" class="control-label">&nbsp;</label></div>
                    <div class="col-sm-4">
                        <input type="hidden" id="room_id" name="room_id" value="<?php echo $detail_data['MST_CATEGORY_ID']; ?>" />
                        <button type="submit" class="btn btn-success btn-block"><!--span class="glyphicon glyphicon-saved"></span--> Save Edit</button>
                    </div>
                    <div class="col-sm-4">
                        <button type="button" class="btn btn-default btn-block" onclick="cancel();"><!--span class="glyphicon glyphicon-circle-arrow-left"></span--> Cancel</button>
                    </div>
                </div>
            <?php } //end if ?>
			</div>
        </div>
	</div>
</form>
